#!/usr/bin/env node

const Koa = require('koa'),log = console.log,task = require('./lib/task.js')

const app = new Koa();


app.use(async (ctx,next)=>{  //M-ms
 const start = Date.now();
 await next();
 const end = Date.now();
 
 log(`${ctx.method} ${ctx.path} cost:${end-start}ms`);

});
app.use(async (ctx,next)=>{
  ctx.body = 'hello koa! task cost'+await task()+'ms';
})

app.listen(8080);

